const TransformPages = require('uni-read-pages');
const { webpack } = new TransformPages();


module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.DefinePlugin({
        ROUTES: webpack.DefinePlugin.runtimeValue(() => {
          const tfPages = new TransformPages({
            includes: ['path', 'name', 'aliasPath', 'icon'] // 需要获取包含的字段，跟 pages.json 的字段对应
          });
          return JSON.stringify(tfPages.routes);
        }, true)
      })
    ]
  },
  devServer: {
    proxy: {
      '/talent': {
        target: 'http://www.njjinrui.cn:7002',
        changeOrigin: true,
        // pathRewrite: {
        //   '^/mb-terminal-service': '/mb-terminal-service'
        // },
		pathRewrite: {
		  '^/talent': '/talent'
		},
        onProxyReq: (proxyReq, req) => {
          console.log('代理请求触发，请求路径:', req.path);
          console.log('333333');
          // 设置其他请求头
          proxyReq.setHeader('Cookie', 'Admin-Token=896370f4-658b-48b2-bdfb-95cd5a3fcfd1;LP=a-N1eurVRz6BQkSMXyvh0-_aprfa14pCAV_00AeYESGB69fSZ5Q3zKXa8zPAq97JAALh_saOvW7DafOt6EOtQVRj9QUQP-B6Wi2jGQfq8zso-wJnxdhGWmaiWDbmEr3sh6magIgu_vcaM4lBJzHGjeWdNVyLQAwMQa1AnYqISvl3e-uxGgqVVyybFbRXAs7xVP_UihcUUt2eT1JCg0OBpzK-BDHYzFT0Nwva_ECtoVvKNcqgJ0tna8S25iHId3di');
          proxyReq.setHeader('X-Custom-Header', 'test-value');
        }
      }
    }
  }
};